<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>QUnit sample</title>
        <script src="http://code.jquery.com/jquery-latest.js">
        </script>
        <link rel="stylesheet" href="http://dev.jquery.com/view/trunk/qunit/testsuite.css" type="text/css" media="screen" />
        <script type="text/javascript" src="http://dev.jquery.com/view/trunk/qunit/testrunner.js">
        </script>
        <script type="text/javascript" src="../src/jquery.color.utils.js">
        </script>
        <script type="text/javascript">
            $(function(){
                try {
                    var result;
                    test("Test For $.isHexadecimalColor", function(){
                        equals(true, $.isHexadecimalColor('#555'), "#555 is true");
                        equals(true, $.isHexadecimalColor('#fff'), "#fff is true");
                        equals(true, $.isHexadecimalColor('#000'), "#000 is true");
                        equals(false, $.isHexadecimalColor('#ggg'), "#ggg is false");
                        equals(false, $.isHexadecimalColor('#0000'), "#0000 is false");
                        equals(false, $.isHexadecimalColor('#00000'), "#00000 is false");
                        equals(true, $.isHexadecimalColor('#000000'), "#000000 is true");
                        equals(false, $.isHexadecimalColor('#0000000'), "#0000000 is false");
                    });
                    
                    test("Test For $.isRGBColor", function(){
                        equals(true, $.isRGBColor('rgb(0,0,0)'), "rgb(0,0,0) is true");
                        equals(true, $.isRGBColor('rgb(0, 0, 0)'), "rgb(0, 0, 0) is true");
                        equals(false, $.isRGBColor('rgb(0,  0,  0)'), "rgb(0,  0,  0) is false");
                        equals(true, $.isRGBColor('rgb(255,255,255)'), "rgb(255,255,255) is true");
                        equals(false, $.isRGBColor('rgb(256,255,255)'), "rgb(256,255,255) is false");
                        equals(true, $.isRGBColor('rgb(99,99,99)'), "rgb(99,99,99) is true");
                        equals(false, $.isRGBColor('#000000'), "#000000 is false");
                        equals(false, $.isRGBColor('aaaa'), "aaaa is false");
                    });
                    
                    test("Test For $.isColor", function(){
                        equals(true, $.isColor('#555'), "#555 is true");
                        equals(true, $.isColor('#fff'), "#fff is true");
                        equals(true, $.isColor('#000'), "#000 is true");
                        equals(false, $.isColor('#ggg'), "#ggg is false");
                        equals(false, $.isColor('#0000'), "#0000 is false");
                        equals(false, $.isColor('#00000'), "#00000 is false");
                        equals(true, $.isColor('#000000'), "#000000 is true");
                        equals(false, $.isColor('#0000000'), "#0000000 is false");
                        equals(true, $.isColor('rgb(0,0,0)'), "rgb(0,0,0) is true");
                        equals(true, $.isColor('rgb(0, 0, 0)'), "rgb(0, 0, 0) is true");
                        equals(false, $.isColor('rgb(0,  0,  0)'), "rgb(0,  0,  0) is false");
                        equals(true, $.isColor('rgb(255,255,255)'), "rgb(255,255,255) is true");
                        equals(false, $.isColor('rgb(256,255,255)'), "rgb(256,255,255) is false");
                        equals(true, $.isColor('rgb(99,99,99)'), "rgb(99,99,99) is true");
                        equals(false, $.isColor('aaaa'), "aaaa is false");
                    });
                    
                    test("Test For $.RGB", function(){
                        result = $.RGB('rgb(0,0,0)');
                        equals(0, result[0], "convert rgb(0,0,0) to [0,0,0]");
                        equals(0, result[1], "convert rgb(0,0,0) to [0,0,0]");
                        equals(0, result[2], "convert rgb(0,0,0) to [0,0,0]");
                        
                        result = $.RGB('#fff');
                        equals(255, result[0], "convert #fff to [255,255,255]");
                        equals(255, result[1], "convert #fff to [255,255,255]");
                        equals(255, result[2], "convert #fff to [255,255,255]");
                        
                        result = $.RGB([2, 3, 5]);
                        equals('rgb(2, 3, 5)', result, "convert [2,3,5] to rgb(2, 3, 5)");
                        
                    });
                    
                    test("Test For $.colorVectorValue", function(){
                        equals(0, $.colorVectorValue('#000000'), "convert #000000 to 0");
                        equals(1, $.colorVectorValue('#000001'), "convert #000001 to 1");
                        equals(1.73, $.colorVectorValue('#010101'), "convert #010101 to 1.73");
                        equals(441.67, $.colorVectorValue('#ffffff'), "convert #ffffff to 441.67");
                        
                    });
                    
                    test("Test For $.colorDecimalValue", function(){
                        equals(0, $.colorDecimalValue('#000000'), "convert #000000 to 0");
                        equals(1, $.colorDecimalValue('#000001'), "convert #000001 to 1");
                        equals(15728640, $.colorDecimalValue('#f00000'), "convert #f00000 to 15728640");
                        equals(16777215, $.colorDecimalValue('#ffffff'), "convert #ffffff to 16777215");
                        
                    });
                    
                    test("Test For $.fmtColor", function(){
                        equals('', $.fmtColor([]), "convert [] to ''");
                        equals('rgb(0, 0, 0)', $.fmtColor('#000'), "convert #000 to rgb(0, 0, 0)");
                        equals('rgb(0, 255, 255)', $.fmtColor('#0ff'), "convert #0ff to rgb(0, 255, 255)");
                        equals('rgb(255, 255, 255)', $.fmtColor('#fff'), "convert #fff to rgb(255, 255, 255)");
                        equals('rgb(255, 255, 255)', $.fmtColor('#ffffff'), "convert #ffffff to rgb(255, 255, 255)");
                        equals('rgb(0, 0, 0)', $.fmtColor('#000000'), "convert #000000 to rgb(0, 0, 0)");
                        equals('rgb(255, 0, 0)', $.fmtColor('#ff0000'), "convert #ff0000 to rgb(255, 0, 0)");
                        equals('#000000', $.fmtColor('rgb(0, 0, 0)'), "convert #000000 to rgb(0, 0, 0)");
                        equals('#ff0000', $.fmtColor('rgb(255, 0, 0)'), "convert #ff0000 to rgb(255, 0, 0)");
                        equals('rgb(0, 0, 0)', $.fmtColor('rgb(0, 0, 0)', 'rgb'), "convert rgb(0, 0, 0) to rgb(0, 0, 0)");
                        equals('#666666', $.fmtColor('#666666', 'hexadecimal'), "convert #666666 to #666666");
                        equals('#666666', $.fmtColor('#666', 'hexadecimal'), "convert #666 to #666666");
                    });
                    
                    test("Test For $.modColor", function(){
                        equals('rgb(5, 0, 0)', $.modColor('#000000', 'r', 5), "modify #000000 to rgb(5, 0, 0)");
                        equals('rgb(0, 255, 0)', $.modColor('#000000', 'g', 255), "modify #000000 to rgb(0, 255, 0)");
                        equals('rgb(15, 0, 32)', $.modColor('#0f0010', 'b', 16), "modify #000000 to rgb(15, 0, 32)");
                        equals('rgb(0, 255, 0)', $.modColor('#000000', 'g', 300), "modify #000000 to rgb(0, 255, 0)");
                        equals('rgb(240, 0, 0)', $.modColor('#FF0000', 'r', -15), "modify #FF0000 to rgb(240, 0, 0)");
                        equals('rgb(255, 0, 0)', $.modColor('#FF0000', 'b', -30), "modify #FF0000 to rgb(255, 0, 0)");
                        equals('rgb(5, 10, 15)', $.modColor('#000000', {
                            'r': 5,
                            'g': 10,
                            'b': 15
                        }), "modify #000000 to rgb(5, 10, 15)");
                        equals('rgb(5, 0, 0)', $.modColor('rgb(0, 0, 0)', 'r', 5), "modify rgb(0, 0, 0) to rgb(5, 0, 0)");
                        equals('rgb(0, 255, 0)', $.modColor('rgb(0, 0, 0)', 'g', 255), "modify rgb(0, 0, 0) to rgb(0, 255, 0)");
                        equals('rgb(15, 0, 32)', $.modColor('rgb(15, 0, 16)', 'b', 16), "modify rgb(15, 0, 16) to rgb(15, 0, 32)");
                        equals('rgb(0, 255, 0)', $.modColor('rgb(0, 0, 0)', 'g', 300), "modify rgb(0, 0, 0) to rgb(0, 255, 0)");
                        equals('rgb(240, 0, 0)', $.modColor('rgb(255, 0, 0)', 'r', -15), "modify rgb(255, 0, 0) to rgb(240, 0, 0)");
                        equals('rgb(255, 0, 0)', $.modColor('rgb(255, 0, 0)', 'b', -30), "modify rgb(255, 0, 0) to rgb(255, 0, 0)");
                        equals('rgb(5, 10, 15)', $.modColor('#000000', {
                            'r': 5,
                            'g': 10,
                            'b': 15
                        }), "modify #000000 to rgb(5, 10, 15)");
                        equals('rgb(5, 10, 15)', $.modColor('#000000', [5, 10, 15]), "modify #000000 to rgb(5, 10, 15)");
                        
                    });
                    
                    test("Test For $.averageColor", function(){
                        equals('rgb(0, 0, 0)', $.averageColor(['#000000']), "average #000000 to rgb(0, 0, 0)");
                        equals('rgb(128, 0, 128)', $.averageColor(['#ff0000', '#0000ff']), "average ['#ff0000','#0000ff'] to rgb(128, 0, 128)");
                        
                    });
                    
                    test("Test For $.colorize", function(){
                        equals('#c0ff1e', $.colorize('coffie'), "coffie to #c0ff1e");
                        equals('#000000', $.colorize('kids'), "kids to #000000");
                        equals('#10aded', $.colorize('loaded'), "loaded to #10aded");
                        equals('#0ccbd0', $.colorize({
                            max: 100,
                            min: 0,
                            value: 50
                        }), "{max:100,min:0,value:50} to #0ccbd0");
                    });
                    
                    test("Test For $.fn.averageColor", function(){
                        equals('rgb(136, 136, 136)', $('#test_averageColor div').averageColor(), "$('#test_averageColor div').averageColor() to rgb(136, 136, 136)");
                    });
                    
                    test("Test For $.fn.sortByColor", function(){
                        result = $('#test_sortByColor div').sortByColor();
                        equals('test_sortByColor_000', result.eq(0).attr('id'), "1st color is test_sortByColor_000");
                        equals('test_sortByColor_002', result.eq(1).attr('id'), "1st color is test_sortByColor_002");
                        equals('test_sortByColor_004', result.eq(2).attr('id'), "1st color is test_sortByColor_004");
                        equals('test_sortByColor_003', result.eq(3).attr('id'), "1st color is test_sortByColor_003");
                        equals('test_sortByColor_001', result.eq(4).attr('id'), "1st color is test_sortByColor_001");
                    });
                } 
                catch (e) {
                }
            });
        </script>
    </head>
    <body>
        <h1>QUnit example</h1>
        <h2 id="banner"></h2>
        <h2 id="userAgent"></h2>
        <ol id="tests">
        </ol>
        <div id="main">
        </div>
        <div id="test_averageColor" style="display:none;">
            <div style="background-color:#808080" class="test">
            </div>
            <div style="background-color:#909090" class="test">
            </div>
        </div>
        <div id="test_sortByColor" style="display:none;">
            <div class="test_sortByColor" id="test_sortByColor_000" style="background-color:#000000;border:#999999;">
            </div>
            <div class="test_sortByColor" id="test_sortByColor_001" style="background-color:#900000;border:#000001;">
            </div>
            <div class="test_sortByColor" id="test_sortByColor_002" style="background-color:#000001;border:#010100;">
            </div>
            <div class="test_sortByColor" id="test_sortByColor_003" style="background-color:#010000;border:#010000;">
            </div>
            <div class="test_sortByColor" id="test_sortByColor_004" style="background-color:#000100;border:#000101;">
            </div>
        </div>
    </body>
</html>
